using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rotempco.Core.Logging.Objects;
using Rotempco.Core.Logging.Logic;
using Rotempco.Core.Logging.EntityObjects.Objects;

namespace Rotempco.Core.Logging
{
    /// <summary>
    /// Logs the events by emailing them to the mail recipients
    /// </summary>
    public class Logit
    {
        public delegate void LogitDelegate(LogStack logEntry);
        public static event LogitDelegate LogitEvent;

        static Logit()
        {
            Log.LogEvent += new Log.LogDelegate(Log_LogEvent);
        }
        
        static void Log_LogEvent(LogStack logEntry)
        {
            if (LogitEvent != null)
                LogitEvent(logEntry);
        }

        public static void Write(string message, Exception exception = null, int extraSteps = 1)
        {
            try
            {
                Log.LogNow(message, exception, extraSteps);
            }
            catch (Exception)
            {
                // TOO BAD
            }
        }
    }
}
